package com.cg.controller;

import com.cg.dto.Result;
import com.cg.dto.ResultUtils;
import com.cg.entity.Department;
import com.cg.service.DepartmentService;
import com.cg.vo.DepartmentInfoVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Department)表控制层
 *
 * @author chengong
 * @since 2024-01-07 12:26:07
 */
@RestController
@RequestMapping("/department")
public class DepartmentController {
    /**
     * 服务对象
     */
    @Resource
    private DepartmentService departmentService;

    /**
     * 根据院区id查询科室
     */
    @GetMapping("/queryDepartmentByBranchId")
    public Result<List<Department>> queryDepartmentByBranchId(@RequestParam("branchId") Integer branchId){
        List<Department> departmentList = departmentService.queryDepartmentByBranchId(branchId);
        return ResultUtils.returnDataSuccess(departmentList);
    }

    /**
     * 根据科室名称模糊查询科室列表
     */
    @GetMapping("/queryDepartmentByDepartmentName")
    public Result<List<Department>> queryDepartmentByDepartmentName(@RequestParam("departmentName") String departmentName){
        List<Department> departmentList = departmentService.queryDepartmentByDepartmentName(departmentName);
        return ResultUtils.returnDataSuccess(departmentList);
    }


    /**
     * 根据科室id查询科室详情
     */
    @GetMapping("/queryDepartmentInfo")
    public Result<DepartmentInfoVo> queryDepartmentInfo(@RequestParam("departmentId") Integer departmentId){
        DepartmentInfoVo departmentInfoVo = departmentService.queryDepartmentInfo(departmentId);
        return ResultUtils.returnDataSuccess(departmentInfoVo);
    }
}

